<script setup>
const props = defineProps({
  data: {
    type: Array,
    default: () => [
    ],
  },
  ready: {
    type: Boolean,
    default: false,
  },
  dict: {
    type: Object,
    default: () => ({}),
  },
})

const isNoData = computed(() => props.ready && !props.data.length)
</script>

<template>
  <section class="store-material">
    <UiAutoScroll v-show="data.length" :list="data" :speed="3" :wait-time="2000" :single-height="320" grid="2">
      <div v-for="(item, index) in data" :key="index" class="store-material__item">
        <div class="store-material__wrap">
          <div class="inventory-type" :class="[['0', '1'].includes(item.inventoryType) && 'ready', ['2', '3'].includes(item.inventoryType) && 'done']">
            {{
              ['0', '1'].includes(item.inventoryType) ? '销毁' : (['2', '3'].includes(item.inventoryType) ? '已销' : '')
            }}
          </div>
          <div class="bin-number">
            {{ item.locationNo }}
          </div>
          <div style="display: flex;">
            <div class="label">
              类型 :
            </div>
            <div class="value" style="margin-left: 4px;">
              {{ dict[item.inventoryType] || item.inventoryType || '--' }}
            </div>
          </div>
          <div class="label">
            入库时间 :
          </div>
          <div class="value">
            {{ item.enterTime }}
          </div>
          <div v-show="item.orderNo" class="label">
            单号 :
          </div>
          <div v-show="item.orderNo" class="value">
            {{ item.orderNo || '--' }}
          </div>
        </div>
      </div>
    </UiAutoScroll>
    <UiEmpty v-show="isNoData" />
  </section>
</template>

<style lang='scss' scoped>
.store-material {
  height: 100%;
  padding: 20px 0;

  &__item {
    position: relative;
    height: 172px;
    background: linear-gradient(271deg, #73a3cc01, #73a3cc20 100%);
    border: 1px solid;
    border-radius: 2px;
    border-image: linear-gradient(180deg, #73a3cc00, #73a3cc 65%, #73a3cc00 100%) 1 1;
  }

  &__wrap {
    height: 100%;
    padding: 0 16px;

    .bin-number {
      margin: 10px 0;
      font-weight: 600;
    }

    .label,.value {
      line-height: 1.45;
    }
  }

  .store-material__wrap{

    .inventory-type{
      position: absolute;
      top: 0;
      right: 0;

      &.ready, &.done {
        width: 56px;
        height: 20px;
        padding-left: 8px;
        font-size: 12px;
        line-height: 20px;
        text-align: center;
      }

      &.ready {
        background: linear-gradient(90deg, #fa9d4300, #fa9d43 100%);
      }

      &.done {
        background: linear-gradient(90deg, #6693c500, #6693c5 100%);
      }
    }
  }
}
</style>
